package com.cxs.distributedencrypt.util;

import ohos.app.Context;
import ohos.data.DatabaseHelper;
import ohos.data.preferences.Preferences;

public class PrefUtils {

    static Preferences preferences = null;
    final static String PREFERENCES_NAME = "HarmonyOS_Preferences";

    /**
     * 获取轻量级数据库
     * @param context
     * @return
     */
    public static Preferences getPreferences(Context context) {
        if (preferences != null) {
            return preferences;
        }
        // context入参类型为ohos.app.Context。
        DatabaseHelper databaseHelper = new DatabaseHelper(context);
        preferences = databaseHelper.getPreferences(PREFERENCES_NAME);
        return preferences;
    }

    private PrefUtils() {}
}
